file(GLOB_RECURSE LSTACK_HEADERS
        "include/*.h"
)

file(GLOB_RECURSE LSTACK_SOURCES
        "api/*.c"
        "apps/*.c"
        "core/*.c"
        "netif/*.c"
)

set(lstack_SEC_FLAGS
        -Wall
        -Werror
        -fstack-protector-strong
        -Wno-deprecated-declarations
        -fPIC
        -D_FORTIFY_SOURCE=2
)

SET(lstack_LINKER_SEC_FLAGS
        -Wl,-z,relro,
        -Wl,-z,now
        -Wl,-z,noexecstack
)

set(lstack_EXTRA_FLAGS
        -D__USE_GNU=1
        -D_GNU_SOURCE=1
        -O2
        -g
)

add_library(lstack SHARED ${LSTACK_SOURCES} ${LSTACK_HEARERS})

target_include_directories(lstack BEFORE PRIVATE
        ${SOURCE_DIR}
        ${SOURCE_DIR}/lwip
        ${SOURCE_DIR}/lwip/include
        ${SOURCE_DIR}/common
#        ${CMAKE_CURRENT_SOURCE_DIR}/api
#        ${CMAKE_CURRENT_SOURCE_DIR}/core
        ${CMAKE_CURRENT_SOURCE_DIR}/include
#        ${CMAKE_CURRENT_SOURCE_DIR}/netif
)

target_link_libraries(lstack PRIVATE
        -ldl -lm -lpthread -lrt -lnuma -lconfig -lboundscheck
)

message("lstack: include directories: ${SOURCE_DIR}/lwip ${SOURCE_DIR}/common ")

target_link_libraries(lstack PRIVATE gazelle_common lwip)

#target_include_directories(lstack ${dpdk_INCLUDE_DIRS})
#target_link_libraries(lstack ${dpdk_LIBRARIES})
target_link_libraries(lstack PRIVATE PkgConfig::dpdk)

target_compile_options(lstack PRIVATE
        ${lstack_SEC_FLAGS}
        ${lstack_EXTRA_FLAGS}
)

target_link_options(lstack PRIVATE
    ${lstack_LINKER_SEC_FLAGS}
)

